package cn.zhfeat.hatch.web.controller.system;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.zhfeat.core.base.BaseResultModel;
import cn.zhfeat.hatch.dto.company.CompanyDepartmentDto;
import cn.zhfeat.hatch.entity.company.CompanyDepartment;
import cn.zhfeat.hatch.web.service.IDepartmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

/**
 * @description: 部门信息相关控制层
 *
 * @author ZhangHao
 * @date 2018年5月24日 下午1:26:26 
 * @version 1.0.0.1
 */
@Component
@RequestMapping("/department")
public class DepartmentController {

	@Autowired
	private IDepartmentService departmentService;
	
	/**
	 * @description: 查询公司下全部的部门信息，用于展示部门树
	 *
	 * @return 
	 * @author ZhangHao
	 * @date 2018年5月24日 下午1:33:50 
	 * @version 1.0.0.1
	 */
    @RequestMapping(value = "/ajaxSelectAllDepartment")
    @ResponseBody
	public Object ajaxSelectAllDepartment(CompanyDepartmentDto dto) {
		return departmentService.ajaxSelectAllDepartment(dto);
	}
    
    /**
     * @description: 分页查询部门信息
     *
     * @param dto
     * @return 
     * @author ZhangHao
     * @date 2018年5月26日 上午10:02:23 
     * @version 1.0.0.1
     */
    @RequestMapping(value="/ajaxPageInfoByDto")
    @ResponseBody
    public BaseResultModel ajaxPageInfoByDto(CompanyDepartmentDto dto){
    	return departmentService.ajaxPageInfoByDto(dto);
    }
    
    /**
     * @description: 新增部门信息
     *
     * @param entity
     * @return 
     * @author ZhangHao
     * @date 2018年5月26日 下午2:35:47 
     * @version 1.0.0.1
     */
    @RequestMapping(value="/ajaxCreateDepartment")
    @ResponseBody
    public BaseResultModel ajaxCreateDepartment(CompanyDepartment entity){
    	return departmentService.ajaxCreateDepartment(entity);
    }
    
    /**
     * @description: 编辑部门信息
     *
     * @param entity
     * @return 
     * @author ZhangHao
     * @date 2018年5月26日 下午4:00:06 
     * @version 1.0.0.1
     */
    @RequestMapping(value="/ajaxEditDepartment")
    @ResponseBody
    public BaseResultModel ajaxEditDepartment(CompanyDepartment entity) {
    	return departmentService.ajaxEditDepartment(entity);
    }
    
    /**
     * @description: 删除部门
     *
     * @param entity
     * @return 
     * @author ZhangHao
     * @date 2018年5月29日 上午10:21:08 
     * @version 1.0.0.1
     */
    @RequestMapping(value="/alaxDeleteDepartment")
    @ResponseBody
    public BaseResultModel alaxDeleteDepartment(CompanyDepartment entity) {
    	return departmentService.alaxDeleteDepartment(entity);
    }
    
    /**
     * @description: 导出企业下的部门
     *
     * @param dto
     * @return 
     * @author ZhangHao
     * @date 2018年6月21日 下午2:29:42 
     * @version 1.0.0.1
     */
    @RequestMapping(value="/exportDepartmentList")
    @ResponseBody
    public BaseResultModel exportDepartmentList(HttpServletResponse response,CompanyDepartmentDto dto) {
    	return departmentService.exportDepartmentList(response,dto);
    }
    
    /**
     * @description: 导入部门层级 
     *
     * @param file
     * @return 
     * @author ZhangHao
     * @date 2018年6月22日 上午9:29:01 
     * @version 1.0.0.1
     */
    @RequestMapping(value = "/importdepartment")
    @ResponseBody
    public BaseResultModel importdataManage(MultipartFile file) {
        return departmentService.importdataManage(file);
    }
    
    /**
     * @description: 导出导入部门失败的列表
     *
     * @param request
     * @param response 
     * @author ZhangHao
     * @date 2018年6月26日 上午10:33:00 
     * @version 1.0.0.1
     */
	@RequestMapping(value = "/exportListError")
    public void exportListError(HttpServletRequest request, HttpServletResponse response) {
		departmentService.exportListError(request,response);
    }
}
